package fr.oz.core.datas 
{
	/**
	 * ...
	 * @author Fazermokeur
	 */
	public class ProfilListDatas
	{
		/*<name>working day</name>
			<time>
				<hour>08</hour>
				<minut>19</minut>
			</time>
			<activated>true</activated>
			<dayInWeek><![CDATA[1|1|0|1|1|0|0]]></dayInWeek>
			<colors>
				<gradient>
					<start hour="07" minut="35"><![CDATA[0x21f455]]></start>
					<end hour="07" minut="55"><![CDATA[0xab00ab]]></end>
				</gradient>
			</colors>
			<music>
				<!-- @TODO créer les datas playlists etc -->
			</music>*/
		public var _node:XML;
		
		private var _activated:Boolean;
		private var _ID:int;
		
		public var name:String;
		public var time_hour:String;
		public var time_minut:String;
		//public var color:ColorGradientData
		public var color:XMLList;
		public var dayInWeek:String;
		
		public function ProfilListDatas(node:XML) 
		{
			_activated = (node.activated == "true") ? true : false ;
			name = node.name;
			time_hour = node.time.hour;
			time_minut = node.time.minut;
			color = node.colors;
			dayInWeek = node.dayInWeek;
			_node = node;
			_ID = node.@id;
		}
		
		public function getString():String
		{
			return _node.toString();
		}
		
		public function get activated():Boolean { return _activated; }
		
		public function set activated(value:Boolean):void 
		{
			_activated = value;
		}
		
		public function get ID():int { return _ID; }
		
		public function set ID(value:int):void 
		{
			_ID = value;
		}

		
		public function generateNode():void
		{
			var str:String = "<profil id=\"" + ID + "\" active=\"" + _activated + "\">"+"\n";
			str += "	<name>" + name + "</name>"+"\n";
			str += "		<time>"+"\n";
			str += "			<hour>" + time_hour + "</hour>"+"\n";
			str += "			<minut>" + time_minut + "</minut>"+"\n";
			str += "		</time>"+"\n";
			str += "		<activated>" + activated + "</activated>"+"\n";
			str += "	<dayInWeek><![CDATA[" + dayInWeek + "]]></dayInWeek>"+"\n";
			str += "	" + color+""+"\n";
			str += "	<music>"+"\n";
			str += "		<!-- @TODO créer les datas playlists etc -->"+"\n";
			str += "	</music>"+"\n";
			str += "</profil>"+"\n";
			
			trace("4: " + str);
			_node = new XML(str);
		}
		
	}

}